
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加员工信息</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${WEB_PATH}/resources/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/bootstrap-table/bootstrap-editable.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/style.min.css?v=5.0.0" rel="stylesheet"><base target="_blank">
	<link href="${WEB_PATH}/resources/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
	
</head>

<style>
.chosen-single.chosen-default.error {
    border: 1px solid #fbc2c4;
    background: rgb(251, 227, 228);
    /* color: #8a1f11; */
}
</style>
<body>
	<div class="col-sm-12">
		<form class="m-t" id="editform">
			  <input  name="ID" id="ID"  value="${testEquipment.ID}"  type="hidden">
    		 <div class="row">
    		 	<div class="col-sm-4"> 
                    <div class="form-group">
                        <label>所属检验机构：</label>
                         <select data-placeholder="选择所属检验机构" id="JYJGID" name="JYJGID"  class="chosen-select form-control" >
                                      <option  value="" hassubinfo="true" ></option>
	                          <#list list as org >
						              <option value="${org.ID}" <#if testEquipment.JCJG.ID = org.ID> selected="selected" </#if> hassubinfo="true">${org.JYJGMC}</option>
						      </#list>
						  </select>
                    </div>
                </div>
               <div class="col-sm-4"> 
                    <div class="form-group">
                        <label>所属检验线：</label>
                         <select data-placeholder="选择所属检验线" id="JCXID" name="JCXID"  class="chosen-select form-control" >
                          	<option  value="" hassubinfo="true" ></option>
                          	 <#list linList as map >
                          	 	 <option value="${map['ID']}" hassubinfo="true" <#if testEquipment.JCX.ID = map['ID']> selected="selected" </#if>  >${map['JCXMC']}</option>
						      </#list>
						 </select>
                    </div>
                </div>
                 <div class="col-sm-4">
                    <div class="form-group">
                        <label>规格：</label>
                        <input type="text" class="form-control" id="GG" value="${testEquipment.GG}" name="GG" placeholder="请输入规格" />
                    </div> 
                </div>
             </div>
             <div class="row">
                 <div class="col-sm-4">
                    <div class="form-group">
                        <label>检测设备名称：</label>
                        <input type="text" class="form-control" id="JCSBMC" value="${testEquipment.JCSBMC}" name="JCSBMC" placeholder="请输入检测设备名称" />
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>设备认证编码：</label>
                        <input type="text" class="form-control" id="SBRZBM" value="${testEquipment.SBRZBM}"  name="SBRZBM" placeholder="请输入设备认证编码" />
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>检测设备类型：</label>
                          <select data-placeholder="选择检测设备类型" id="JCSBLXID" name="JCSBLXID"  class="chosen-select form-control" >
                              <option  value="" hassubinfo="true" ></option>
	                          <#list typeList as type >
						              <option value="${type.ID}" hassubinfo="true" <#if testEquipment.JCSBLX.ID = type.ID> selected="selected" </#if> >${type.NAME}</option>
						      </#list>
						  </select>
                    </div> 
                </div>
            </div>  
             <div class="row">
    		 	  <div class="col-sm-4">
                    <div class="form-group">
	                    <label >是否要自检：</label>
	                    <div class="col-sm-4 form-control">
	                        <div class="radio radio-success radio-inline">
	                           <input type="radio"   value="${testEquipment.SFZJ}"  name="SFZJ" id="JCXZD1" <#if testEquipment.SFZJ> checked="" </#if> >
	                           <label for="JCXZD1">是</label>
	                        </div>
	                        <div class="radio radio-warning radio-inline">
	                            <input type="radio"  id="JCXZD2"  value="${testEquipment.SFZJ}" name="SFZJ"  <#if !testEquipment.SFZJ> checked="" </#if>>
	                            <label for="JCXZD2">否</label>
	                        </div>
	                    </div>
	                </div> 
                 </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>系列：</label>
                        <input id="text" name="XL" id="XL"   type="text" value="${testEquipment.XL}" class="form-control" placeholder="请输入系列">
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>型号：</label>
                        <input id="text" name="XH" id="XH"   type="text" value="${testEquipment.XH}"  class="form-control" placeholder="请输入型号">
                    </div> 
                </div>
             </div>
             <div class="row">
               
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>设备制造厂：</label>
                        <input type="text" class="form-control" id="SBZZC"  value="${testEquipment.SBZZC}" name="SBZZC" placeholder="请输入设备制造厂" />
                    </div> 
                </div>
                <div class="col-sm-4">
                      <div class="form-group">
                        <label>设备有效期：</label>
                        <input type="text" class="form-control" id="SBBDYXQ" name="SBBDYXQ" value="${testEquipment.SBBDYXQ}" />
                    </div> 
                </div>
            </div>  
        </form> 
		</div>
	</div>
    <script src="${WEB_PATH}/resources/js/jquery.min.js?v=2.1.4"></script>
    <script src="${WEB_PATH}/resources/js/ajax.extend.js"></script>
    <script src="${WEB_PATH}/resources/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="${WEB_PATH}/resources/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/wizard/jquery.bootstrap.wizard.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.method.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/layer/layer.js"></script> 
	 <script src="${WEB_PATH}/resources/js/city-picker.data.js"></script>
	<script src="${WEB_PATH}/resources/js/city-picker.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/chosen/chosen.jquery.js"></script>
	 <script>
	$(function(){
	    $("#JYJGID").chosen({width:'100%'}); 
	    $("#JCXID").chosen({width:'100%'});
	    $("#JCSBLXID").chosen({width:'100%'});
	    
	    
	    $("#JCXID").change(function(){
		 	//$("#JCFFIDS-error").remove();
		 	$("#JCXID-error").remove();
		 	$("ul.chosen-choices").removeClass("error");
		});
		
		
	      //设备标定有效期
	    $("#SBBDYXQ").datepicker({
	        keyboardNavigation: !1,
	        forceParse: !1,
	        autoclose: !1
	    });
		
		
		$("#JYJGID").change(function(){
			 	var id = $(this).val();
			 	$("#JYJGID-error").remove();
			 	 $.yilinAjax({
			   	  	type:'GET',
			   	  	loadmsg:'努力提交中......',
			   	  	url:'${WEB_PATH}/reg/testequipment/getTestline.do?JYJGID='+id,
			   	  	btn:null,
	        		errorcallback:null,
	        		successcallback:function(data){
	        		    $("#JCXID").empty();
	        		    $("#JCXID").chosen("destroy");
	        		    
		        		$.each(data, function(key, value) {
		        			$("#JCXID").append('<option value="'+value.ID+'">'+value.JCXMC+'</option>');
		        		 	console.log(value.JCXMC) 
						}); 
	        			$("#JCXID").chosen();
	        		}
		});
			
		});
	    
	     
    });
	var e = "<i class='fa fa-times-circle'></i> ";
	var $editformvalidate =  $('#editform').validate({
	      ignore:".ignore",
		  rules: {
		     JYJGID: {
		      required: true
		    },
		    JCXID: {
		      required: true
		    },
		    JCSBMC: {
		      required: true
		    },
		    JCSBBH: {
		      required: true
		    },
		    
		    JCSBLXID: {
		      required: true
		    },
		    JCXZD:{
		      required: true
		    }
		  },
		  messages: {
            name: {
                remote:e+"商户名已存在，请重新输入！"
            }
          },
		  errorPlacement: function(error, element) {
		      if(element.get(0).id == "JCXID"){
		     		if($("#JCXID").val()==null||$("#JCXID").val()==""){
		     			element.next().find("a.chosen-default").addClass("error");
		     		}
            	}
            	if(element.get(0).id == "JYJGID"){
		     		if($("#JYJGID").val()==null||$("#JYJGID").val()==""){
		     			element.next().find("a.chosen-default").addClass("error");
		     		}
            	}
            	
            	if(element.get(0).id == "JCSBLXID"){
		     		if($("#JCSBLXID").val()==null||$("#JCSBLXID").val()==""){
		     			element.next().find("a.chosen-default").addClass("error");
		     		}
            	}
            	
		  		if(element.get(0).id == "XZQHMC"){
            		$('#XZQHMC').citypicker("setError");
            	}
          },
          success:function(element){
             if(element.prop("tagName")=='SELECT'){
		          console.log(element);
		     }
	         
	      }
	});
     //添加检测线信息#addForm
 	function saveEditForm(){
 		if($('#editform').valid()){
 			 var addformJson = $('#editform').serializeJson();
 			  var JCFFIDS = $("#JCFFIDS").val() != null ? $("#JCFFIDS").val().join(","):$("#JCFFIDS").val();
 			 addformJson.JCFFIDS = JCFFIDS;
			 $.yilinAjax({
		   	  	type:'POST',
		   	  	loadmsg:'努力提交中......',
		   	  	url:'${WEB_PATH}/reg/testequipment/edit.do',
		   	  	data:addformJson,
		   	  	btn:null,
        		errorcallback:null,
        		successcallback:success
		   	 });
    	}
 	}
 	
 	function success(result){
 		if(result.success == true){
	    	layer.alert('<font color="#1ab394">'+result.msg+'</font>', {
			  	skin: 'layui-layer-molv',
			  	icon: 1,
			  	closeBtn: 0
			},function(){
				parent.$("#exampleTableEvents").bootstrapTable('refresh');
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); 
			});
		}else{
			$('#saveBut').attr("disabled",false); 
		 	$('#subBut').attr("disabled",false);       
	    	layer.alert('<font color="red">'+result.msg+'</font>', {
			  skin: 'layui-layer-molv' ,
			  closeBtn: 0,
			  icon: 5,
			});
		}
 	}
  </script>
</body>
</html>